package com.qcby.springbootdemotest.task;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;

public class test {

    public static void main(String[] args) throws IOException {
        String url = "https://sou.zhaopin.com/?jl=530&p=1&kw=java";
        /* Document document=Jsoup.connect(url).get();
       //System.out.println(document);
        Elements elements=document.getElementsByClass("joblist-box__item");
        for(Element element:elements){
            String salary=element.getElementsByClass("jobinfo__salary").text();
            String company=element.getElementsByClass("companyinfo_name").text();
            System.out.println(price+" " + company);
        }
        */
        Document scriptHtml = Jsoup.connect(url)
                .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7")
                .header("Accept-Encoding", "gzip, deflate, br, zstd")
                .header("Accept-Language", "zh-CN,zh;q=0.9")
                .header("Cache-Control", "max-age=0")
                //.header("Connection", "keep-alive")
                //.header("Upgrade-Insecure-Requests", "1")
                //.header("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36")
                .header("Cookie", "x-zp-client-id=800ca9ea-8d55-447f-8ead-005541ae2071; FSSBBIl1UgzbN7NO=5VXkaqiIHfezhD310dHXoExHrEp3cYPCRH1VsmIFO5VXAvNhD_2_NFHA5WdujUKkbTGRgQyF.Ajx85E1Zgy07hG; sajssdk_2015_cross_new_user=1; _uab_collina=172005533531645859904792; Hm_lvt_21a348fada873bdc2f7f75015beeefeb=1720055335; locationInfo_search={%22code%22:%22570%22%2C%22name%22:%22%E4%BF%9D%E5%AE%9A%22%2C%22message%22:%22%E5%8C%B9%E9%85%8D%E5%88%B0%E5%B8%82%E7%BA%A7%E7%BC%96%E7%A0%81%22}; 1420ba6bb40c9512e9642a1f8c243891=5719b348-57b3-4baf-b657-11270a71ee0b; zp_passport_deepknow_sessionId=2e9716ffsb5ecc438b9e98c39c9911be6b1f; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%221204446488%22%2C%22first_id%22%3A%221907b498970618-01eab826c4cb1d4-26001f51-1327104-1907b498971daf%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTkwN2I0OTg5NzA2MTgtMDFlYWI4MjZjNGNiMWQ0LTI2MDAxZjUxLTEzMjcxMDQtMTkwN2I0OTg5NzFkYWYiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIxMjA0NDQ2NDg4In0%3D%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%221204446488%22%7D%2C%22%24device_id%22%3A%221907b498970618-01eab826c4cb1d4-26001f51-1327104-1907b498971daf%22%7D; at=a666ffa84a184014bbd49f00d984a5ec; rt=0c8b8fe4bc9b45fca060d6b345883a19; sts_deviceid=1907b606fc24bc-066552e7f60a7f-26001f51-1327104-1907b606fc3cff; ZP_OLD_FLAG=false; sts_sg=1; sts_evtseq=1; sts_sid=1907b6076a9ba5-04c27603cdb8d1-26001f51-1327104-1907b6076aa1e6a; sts_chnlsid=Unknown; zp_src_url=https%3A%2F%2Fsou.zhaopin.com%2F; ZL_REPORT_GLOBAL={%22/resume/new%22:{%22actionid%22:%2258da05ff-22ee-4993-80e8-4e44b4086eeb%22%2C%22funczone%22:%22addrsm_ok_rcm%22}}; Hm_lpvt_21a348fada873bdc2f7f75015beeefeb=1720056885; FSSBBIl1UgzbN7NP=5RLUZJDFmdkAqqqDA8CIjGqw6ZYSNoCq.bnk5tLJyjitcyRLUC5kUNCx_bYSV_ZVK4ZkGjy7kPtCcqVqmPkXJ4Ckbbx5fpfuE9v2V8rZI7tL1.UCW5kzPsDD4lLvsUHACDPw82E_u_g0MtYz7USCiu7Sxwcsy.ksxdkgfz6NvLwoAPUbpr9HGFSsMwGLAKnIwGqrdOIXwtnePL3IJaU6rW5cQMhgggOBOaSL_z5CiTckLUTs61KVsd7jyI6ZmHQISXBPA8XyW59SAdIeudRC2PuhwtUhon3BlZ.kXxetrxH5sJBp7ceTdyn8pqoDqUc_CKKdbTxDSY6gWUXLSMQFsoS")
                .header("Priority", "u=0, i")
                .header("Sec-Ch-Ua","\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Google Chrome\";v=\"126\"")
                .header("Sec-Ch-Ua-Mobile","?0")
                .header("Sec-Ch-Ua-Platform","\"Windows\"")
                .header("Sec-Fetch-Dest","document")
                .header("Sec-Fetch-Mode","navigate")
                .header("Sec-Fetch-Site","same-origin")
                .header("Sec-Fetch-User","?1")
                .header("Upgrade-Insecure-Requests","1")
                .header("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36")
                .timeout(500000)
                .get();
        Elements content = scriptHtml.getElementsByClass("joblist-box__item");
        for (Element element : content) {
            String price = element.getElementsByClass("jobinfo__salary").text();
            String company = element.getElementsByClass("companyinfo__name").text();
            System.out.println(price + " " + company);
        }

    }
}
